from django.db import models
from .utils import PROTECT


# Create your models here.


class Author(models.Model):
    user_name = models.CharField(verbose_name="姓名", max_length=200)

    class Meta:
        verbose_name = "作者"
        verbose_name_plural = "作者"

    def __str__(self):
        return self.user_name


class Article(models.Model):
    title = models.CharField(verbose_name="标题", max_length=200)
    author = models.ForeignKey(to=Author, verbose_name="作者", on_delete=PROTECT)
    content = models.TextField(verbose_name="内容")

    class Meta:
        verbose_name = "文章"
        verbose_name_plural = "文章"

    def __str__(self):
        return self.title
